extends IEffectBehavior


class_name HitSplit
"""
分裂效果
"""


## 分裂的角度
@export_range(0, 360, 1, "radians") var split_angle: float = deg_to_rad(10)


func support() -> Array:
    return [0, CharacterComponent.Event.ON_HIT_EXECUTE]

## 处理子弹初始化事件
func do_event(character: CharacterComponent, v: EffectValue, e: CharacterEvent) -> void:
    var source: ProjectileResource = e.meta.source
    var angles: Array = ShapeDraw.get_split_angles(v.value, split_angle)
    var start_angle: float = source.start_direction.angle()
    for i in range(len(angles)):
        var value: float = angles[i] + start_angle
        source.start_direction = Vector2.from_angle(value)
        e.meta.projectile.weapon.spawn(source)
    e.cancel()
